home *** CD-ROM | disk | FTP | other *** search
- VERSION 4.00
- Begin VB.Form Form1
- BorderStyle = 3 'Fixed Dialog
- Caption = "VB4 Tray"
- ClientHeight = 2970
- ClientLeft = 1335
- ClientTop = 1860
- ClientWidth = 5265
- Height = 3375
- Left = 1275
- LinkTopic = "Form1"
- MaxButton = 0 'False
- MinButton = 0 'False
- ScaleHeight = 2970
- ScaleWidth = 5265
- ShowInTaskbar = 0 'False
- Top = 1515
- Width = 5385
- Begin VB.CheckBox Check1
- Caption = "Check1"
- Height = 255
- Left = 4200
- TabIndex = 17
- Top = 2640
- Width = 495
- End
- Begin VB.TextBox Text2
- Height = 285
- Left = 360
- TabIndex = 16
- Text = "Text1"
- Top = 2040
- Width = 1335
- End
- Begin VB.CheckBox chkFlash
- Caption = "Flash"
- Height = 255
- Left = 180
- TabIndex = 11
- Top = 600
- Width = 795
- End
- Begin VB.Timer Timer1
- Interval = 1000
- Left = 4080
- Top = 1020
- End
- Begin VB.PictureBox Picture1
- Height = 315
- Left = 120
- ScaleHeight = 255
- ScaleWidth = 315
- TabIndex = 10
- Top = 1620
- Width = 375
- End
- Begin VB.CommandButton cmdUnload
- Caption = "Unload"
- Height = 375
- Left = 4080
- TabIndex = 9
- Top = 540
- Width = 1095
- End
- Begin VB.CommandButton cmdClose
- Caption = "Close"
- Height = 375
- Left = 4080
- TabIndex = 8
- Top = 60
- Width = 1095
- End
- Begin VB.CommandButton cmdChangeTip
- Caption = "Change"
- Height = 315
- Left = 3120
- TabIndex = 5
- Top = 1200
- Width = 735
- End
- Begin VB.TextBox txtTip
- Height = 315
- Left = 60
- MaxLength = 63
- TabIndex = 4
- Text = "This is the tooltip"
- Top = 1200
- Width = 3015
- End
- Begin VB.OptionButton Option1
- Caption = "Option1"
- Height = 255
- Index = 3
- Left = 3300
- TabIndex = 3
- Top = 600
- Width = 255
- End
- Begin VB.OptionButton Option1
- Caption = "Option1"
- Height = 255
- Index = 2
- Left = 2700
- TabIndex = 2
- Top = 600
- Width = 255
- End
- Begin VB.OptionButton Option1
- Caption = "Option1"
- Height = 255
- Index = 1
- Left = 2100
- TabIndex = 1
- Top = 600
- Width = 255
- End
- Begin VB.OptionButton Option1
- Caption = "Option1"
- Height = 255
- Index = 0
- Left = 1500
- TabIndex = 0
- Top = 600
- Value = -1 'True
- Width = 255
- End
- Begin VB.Label Label5
- Caption = "http://www.mmcsoftware.com"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 255
- Index = 4
- Left = 60
- TabIndex = 15
- Top = 2700
- Width = 3855
- End
- Begin VB.Label Label5
- Caption = "Sample Code by David Warren, MMC Software "
- Height = 255
- Index = 3
- Left = 60
- TabIndex = 14
- Top = 2460
- Width = 3855
- End
- Begin VB.Label Label5
- Caption = "This is a gray icon used for the flash "
- Height = 195
- Index = 2
- Left = 1800
- TabIndex = 13
- Top = 2100
- Width = 2595
- End
- Begin VB.Label Label5
- Caption = "This is the Picturebox that recieves the messages"
- Height = 195
- Index = 1
- Left = 540
- TabIndex = 12
- Top = 1680
- Width = 3855
- End
- Begin VB.Image Image2
- BorderStyle = 1 'Fixed Single
- Height = 540
- Left = 4500
- Picture = "tray.frx":0000
- Top = 1920
- Width = 540
- End
- Begin VB.Label Label6
- Caption = "Tooltip in Tray:"
- Height = 195
- Left = 120
- TabIndex = 7
- Top = 1020
- Width = 2055
- End
- Begin VB.Label Label5
- Caption = "Select an Icon"
- Height = 195
- Index = 0
- Left = 120
- TabIndex = 6
- Top = 120
- Width = 1155
- End
- Begin VB.Shape Shape1
- Height = 915
- Left = 60
- Top = 60
- Width = 3855
- End
- Begin VB.Image Image1
- Height = 480
- Index = 3
- Left = 3180
- Picture = "tray.frx":030A
- Top = 120
- Width = 480
- End
- Begin VB.Image Image1
- Height = 480
- Index = 2
- Left = 2580
- Picture = "tray.frx":074C
- Top = 120
- Width = 480
- End
- Begin VB.Image Image1
- Height = 480
- Index = 1
- Left = 1980
- Picture = "tray.frx":0B8E
- Top = 120
- Width = 480
- End
- Begin VB.Image Image1
- Height = 480
- Index = 0
- Left = 1380
- Picture = "tray.frx":0FD0
- Top = 120
- Width = 480
- End
- Attribute VB_Name = "Form1"
- Attribute VB_Creatable = False
- Attribute VB_Exposed = False
- Dim IconIndex As Integer, IntDown As Integer
- Sub MyPopupmenu(x As Integer, y As Integer)
- hMenu = GetMenu(Form2.hwnd)
- hSubMenu = GetSubMenu(hMenu, 0)
- hTray = FindWindow("Shell_TrayWnd", 0&)
- If hTray > 0 Then
- Dim TrayRect As RECT
- Result = GetWindowRect(hTray, TrayRect)
- lResult = TrackPopupMenu(hSubMenu, TPM_RIGHTALIGN, TrayRect.Right, TrayRect.Bottom, 0&, Form2.hwnd, ByVal 0&)
- End If
- End Sub
- Private Sub cmdChangeTip_Click()
- Dim iData As NOTIFYICONDATA
- iData.cbSize = Len(iData)
- iData.hwnd = Picture1.hwnd
- iData.uID = 9999
- iData.uFlags = NIF_TIP
- iData.szTip = (txtTip.Text) & Chr$(0)
- Result = Shell_NotifyIcon(NIM_MODIFY, iData)
- End Sub
- Private Sub cmdClose_Click()
- Me.Hide
- End Sub
- Private Sub cmdUnload_Click()
- Unload Me
- End Sub
- Private Sub Form_Load()
- ' VB4 Tray
- ' Code sample for Visual Basic 4
- ' Copyright
- 1996 by David Warren
- Dim iData As NOTIFYICONDATA
- iData.cbSize = Len(iData)
- iData.hwnd = Picture1.hwnd
- iData.uID = 9999
- iData.uFlags = NIF_MESSAGE + NIF_ICON + NIF_TIP
- iData.uCallbackMessage = WM_LBUTTONDOWN
- iData.hIcon = Image1(0).Picture
- iData.szTip = Text2.Text & Chr$(0)
- Result = Shell_NotifyIcon(NIM_ADD, iData)
- Me.Hide
- End Sub
- Private Sub Form_Unload(Cancel As Integer)
- Dim iData As NOTIFYICONDATA
- iData.cbSize = Len(iData)
- iData.hwnd = Picture1.hwnd
- iData.uID = 9999
- Result = Shell_NotifyIcon(NIM_DELETE, iData)
- End
- End Sub
- Private Sub Image1_Click(Index As Integer)
- Option1(Index).Value = True
- End Sub
- Private Sub Option1_Click(Index As Integer)
- Dim iData As NOTIFYICONDATA
- IconIndex = Index
- iData.cbSize = Len(iData)
- iData.hwnd = Picture1.hwnd
- iData.uID = 9999
- iData.uFlags = NIF_ICON
- iData.uCallbackMessage = WM_LBUTTONDOWN
- iData.hIcon = Image1(IconIndex).Picture
- Result = Shell_NotifyIcon(NIM_MODIFY, iData)
- End Sub
- Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
- Select Case x
- Case TRAY_MSG_MOUSEMOVE
-
- Case TRAY_MSG_LEFTBTN_DOWN
-
- Case TRAY_MSG_LEFTBTN_UP
- MyPopupmenu (x), (y)
- Case TRAY_MSG_LEFTBTN_DBLCLICK
- Me.Show
- Me.SetFocus
- Case TRAY_MSG_RIGHTBTN_DOWN
-
- Case TRAY_MSG_RIGHTBTN_UP
- MyPopupmenu (x), (y)
- Case TRAY_MSG_RIGHTBTN_DBLCLICK
-
- End Select
- End Sub
- Private Sub Timer1_Timer()
- Dim iData As NOTIFYICONDATA
- If Check1.Value = 1 Then
- iData.cbSize = Len(iData)
- iData.hwnd = Picture1.hwnd
- iData.uID = 9999
- If FlashOn Then
- FlashOn = False
- iData.uFlags = NIF_ICON
- iData.hIcon = Image2.Picture
- Result = Shell_NotifyIcon(NIM_MODIFY, iData)
-
- Else
- iData.uFlags = NIF_ICON
- iData.hIcon = Image1(IconIndex).Picture
- Result = Shell_NotifyIcon(NIM_MODIFY, iData)
- FlashOn = True
- End If
- Else
- If FlashOn = False Then
-
- iData.cbSize = Len(iData)
- iData.hwnd = Picture1.hwnd
- iData.uID = 9999
- iData.uFlags = NIF_ICON
- iData.hIcon = Image1(IconIndex).Picture
- Result = Shell_NotifyIcon(NIM_MODIFY, iData)
- FlashOn = True
- End If
- End If
- End Sub
-